package main

import (
	"database/sql"
	"fmt"

	_ "github.com/go-sql-driver/mysql"
)

//查询单行数据
type Doctor struct {
	id      int
	name    string
	age     int
	sex     int
	addTime string
}
type Movie struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Year   int    `json:"year"`
	Genre  string `json:"genre"`
	Poster string `json:"poster"`
}

func main() {
	db, err := sql.Open("mysql", "ding:dyw20020304@tcp(81.68.186.20:3306)/Ding?charset=utf8&parseTime=True")
	if err != nil {
		fmt.Println("sql.Open err = ", err)
		return
	}
	defer db.Close()
	Row := db.QueryRow("select * from tb_movie where id = 3")
	var movie Movie
	fmt.Println(Row.Err())
	Row.Scan(&movie.ID, &movie.Year, &movie.Name, &movie.Genre, &movie.Poster)
	fmt.Println(movie)

}
